/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.xeerkat.xmpp.server.db;

import java.sql.SQLException;
import org.milowski.db.DBConnection;
import org.milowski.db.DBObject;

/**
 *
 * @author alex
 */
public class Group extends DBObject<XMPPDB> {

   User user;
   String name;
   public Group(XMPPDB db,int id,User user,String name)
   {
      super(db,id);
      this.user = user;
      this.name = name;
   }

   public User getUser() {
      return user;
   }
   
   public String getName() {
      return name;
   }
   
   public boolean delete() 
      throws SQLException
   {      
      DBConnection connection = db.getConnection();
      try {
         connection.deleteById(XMPPDB.STATEMENT_DELETE_GROUP_CONTACT_GROUPS, id);
         return connection.deleteById(XMPPDB.STATEMENT_DELETE_GROUP, id)>0;
      } finally {
         db.release(connection);
      }
   }
}
